/*
 * Copyright(C) 2010 the original author or authors.
 *
 * Change History Log
 * ----------------------------------------------------
 * Version: 1.0
 * Date: 2011-5-23
 * Author: wangzl
 * ----------------------------------------------------
 */
package com.seemsea.web.admin.coupon;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.collections.FactoryUtils;
import org.apache.commons.collections.ListUtils;

import com.seemsea.entity.admin.coupon.Coupon;
import com.seemsea.entity.admin.coupon.CouponItem;
import com.seemsea.entity.admin.coupon.Product;

/**
 * 
 * 
 * @author wangzl
 * @since 2011-5-23
 */
public class CouponForm {
	private Product product;
	private Coupon coupon;
	private String action;
	private Integer itemsNum;
	private List<CouponItem> couponItems;
	
	public Product getProduct() {
		if(product == null) product = new Product();
		return product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}
	public Coupon getCoupon() {
		if(coupon == null) {
			coupon = new Coupon();
			coupon.setCouponItems(getCouponItems());
		}
		return coupon;
	}
	public void setCoupon(Coupon coupon) {
		this.coupon = coupon;
	}
	public String getAction() {
		return action;
	}
	public void setAction(String action) {
		this.action = action;
	}
	public Integer getItemsNum() {
		return itemsNum;
	}
	public void setItemsNum(Integer itemsNum) {
		this.itemsNum = itemsNum;
	}
	@SuppressWarnings("unchecked")
	public List<CouponItem> getCouponItems() {
		if(couponItems == null){
			couponItems = ListUtils.lazyList(new ArrayList<CouponItem>(),FactoryUtils.instantiateFactory(CouponItem.class));
		}
		return couponItems;
	}
}
